package com.yifan.spring.event;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author YIFan
 * @Date 2021-7-26 10:03
 * @Version 1.0
 */
@RestController
@RequestMapping("event")
public class EventRequest{

    Logger log = LoggerFactory.getLogger(EventRequest.class);

    @Autowired
    private ApplicationEventPublisher eventPublisher;

    @GetMapping("publish")
    public String publish(String name){
        log.info("EventRequest.publish===>[进入-----]");
        eventPublisher.publishEvent(new UserEvent(name));
        log.info("EventRequest.publish===>[结束-----]");
        return null;
    }

}
